import React from 'react';
import WangEdit from '../../components/common/wangEdit'
import { withRouter } from 'react-router';
import Lbxins from "../../api/lbxin";
interface ITopicProps {
}

const Topic: React.FunctionComponent<ITopicProps> = (props) => {
  const data:any = []
  const getData = (node:any) => {
    console.log(node,'log-node')
    
    if (node.value) {
      data.push({
        data: node.data,
        value: node.value
      })
    }
    if (node.type === 1) {
      node.children.forEach((child:any) => {
        getData(child)
      })
    }
    // console.log(data)
  }
  const htmlToWord = (data:any) => {
    getData(data.children[0])
    // console.log(data,'log-data')
    Lbxins.postData("/default/htmlToWord",data.children[0])
      .then(res => {
        console.log(res,'log-res')
        
        // res.data.map((res: { [x: string]: boolean }) => {
        //   return res["CardToolTipShow"] = false;
        // });
      })
      .catch(err => {
        console.log(err, "log-err");
      });
  }
  return (
    <div className="contentBox">
      <WangEdit saveEdit={htmlToWord} />
    </div>
  );
};

export default withRouter(Topic);
